﻿using MediatR;
using Traceability.APP.Application.Command.Shop;
using Traceability.Domain;
using Traceability.ErrorCode;
using Traceability.Infrerture.Interfaces;

namespace Traceability.APP.Application.CommandHandle.Shop
{
    /// <summary>
    /// 商品信息的显示
    /// </summary>
    public class GetShopAllCommanHandle:IRequestHandler<GetShopAllComman,APIResult<List<Shop_Model>>>
    {
        private readonly IBaseRepository<Shop_Model> ShopDal;

        public GetShopAllCommanHandle(IBaseRepository<Shop_Model> shopDal)
        {
            ShopDal = shopDal;
        }

        public Task<APIResult<List<Shop_Model>>> Handle(GetShopAllComman request, CancellationToken cancellationToken)
        {
            APIResult<List<Shop_Model>> result = new APIResult<List<Shop_Model>>();
            result.Code = StateCode.Ok;
            result.Message = StateCode.Ok.ToString();

            var list = ShopDal.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }


    }
}
